using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using asWins.Forms;

namespace TestMdi
{
	/// <summary>
	/// Summary description for MainMdiForm.
	/// </summary>
	public class MainMdiForm : System.Windows.Forms.Form
	{
		/// <summary>
		/// Entry point 
		/// </summary>
		[STAThread()]
		static void Main()
		{
			Application.Run(new MainMdiForm());
		}

		#region Constructor and Dispose

		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.MenuItem menuItem7;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.MenuItem menuItem9;
		private System.Windows.Forms.MenuItem menuItem11;
		private System.Windows.Forms.MenuItem menuItem12;
		private System.Windows.Forms.StatusBar statusBar1;
		private System.Windows.Forms.StatusBarPanel statusBarPanel1;
		private System.Windows.Forms.StatusBarPanel statusBarPanel2;
		private System.Windows.Forms.StatusBarPanel statusBarPanel3;
		private System.Windows.Forms.StatusBarPanel statusBarPanel4;
		private asWins.Forms.asMdiManager asMdiManager1;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.ComponentModel.IContainer components = null;

		

		/// <summary>
		/// Initialized a new class
		/// </summary>
		public MainMdiForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			Application.Idle += new EventHandler(Application_Idle);
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#endregion

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItem7 = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem11 = new System.Windows.Forms.MenuItem();
			this.menuItem12 = new System.Windows.Forms.MenuItem();
			this.statusBar1 = new System.Windows.Forms.StatusBar();
			this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel4 = new System.Windows.Forms.StatusBarPanel();
			this.asMdiManager1 = new asWins.Forms.asMdiManager();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).BeginInit();
			this.SuspendLayout();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1,
																					  this.menuItem8,
																					  this.menuItem11});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2,
																					  this.menuItem3,
																					  this.menuItem4,
																					  this.menuItem7});
			this.menuItem1.Text = "File";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
			this.menuItem2.Text = "New Form (include many controls)";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.Shortcut = System.Windows.Forms.Shortcut.CtrlM;
			this.menuItem3.Text = "New Form (rich text box)";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 2;
			this.menuItem4.Text = "-";
			// 
			// menuItem7
			// 
			this.menuItem7.Index = 3;
			this.menuItem7.Text = "Exit";
			this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 1;
			this.menuItem8.MdiList = true;
			this.menuItem8.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem9,
																					  this.menuItem5});
			this.menuItem8.Text = "Window";
			// 
			// menuItem9
			// 
			this.menuItem9.Index = 0;
			this.menuItem9.Text = "Close all forms";
			this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 1;
			this.menuItem5.Text = "-";
			// 
			// menuItem11
			// 
			this.menuItem11.Index = 2;
			this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					   this.menuItem12});
			this.menuItem11.Text = "Help";
			// 
			// menuItem12
			// 
			this.menuItem12.Index = 0;
			this.menuItem12.Text = "About";
			this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
			// 
			// statusBar1
			// 
			this.statusBar1.Location = new System.Drawing.Point(0, 531);
			this.statusBar1.Name = "statusBar1";
			this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																						  this.statusBarPanel1,
																						  this.statusBarPanel2,
																						  this.statusBarPanel3,
																						  this.statusBarPanel4});
			this.statusBar1.ShowPanels = true;
			this.statusBar1.Size = new System.Drawing.Size(792, 22);
			this.statusBar1.TabIndex = 1;
			this.statusBar1.Text = "statusBar1";
			// 
			// statusBarPanel1
			// 
			this.statusBarPanel1.Text = "statusBarPanel1";
			// 
			// statusBarPanel2
			// 
			this.statusBarPanel2.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.statusBarPanel2.Text = "statusBarPanel2";
			this.statusBarPanel2.Width = 476;
			// 
			// statusBarPanel3
			// 
			this.statusBarPanel3.Text = "statusBarPanel3";
			// 
			// statusBarPanel4
			// 
			this.statusBarPanel4.Text = "statusBarPanel4";
			// 
			// asMdiManager1
			// 
			this.asMdiManager1.Location = new System.Drawing.Point(0, 0);
			this.asMdiManager1.Name = "asMdiManager1";
			this.asMdiManager1.Size = new System.Drawing.Size(792, 531);
			this.asMdiManager1.Text = "asMdiManager";
			// 
			// MainMdiForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
			this.ClientSize = new System.Drawing.Size(792, 553);
			this.Controls.Add(this.asMdiManager1);
			this.Controls.Add(this.statusBar1);
			this.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(222)));
			this.KeyPreview = true;
			this.Menu = this.mainMenu1;
			this.Name = "MainMdiForm";
			this.Text = "MainMdiForm";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Resize += new System.EventHandler(this.MainMdiForm_Resize);
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		
		private void Application_Idle(object sender, EventArgs e)
		{
			// Update the panels when the program is idle.
			bool isNumLock = (((ushort) Win32API.GetKeyState(0x90 /*VK_NUMLOCK*/)) & 0xffff) != 0;
			bool isCaplock  = (((ushort) Win32API.GetKeyState(0x14 /*VK_CAPITAL*/)) & 0xffff) != 0;

			this.statusBarPanel3.Text = isCaplock ? "CAP": "";
			this.statusBarPanel4.Text = isNumLock ? "NUM": "";
		}

		
		private void MainMdiForm_Resize(object sender, System.EventArgs e)
		{
			this.statusBar1.SizingGrip = !(this.WindowState == FormWindowState.Maximized);
		}

		private void menuItem2_Click(object sender, System.EventArgs e)
		{
			ManyControlForm frm = new ManyControlForm();
			this.asMdiManager1.AddForm(frm);
		}

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			DummyForm frm = new DummyForm();
			this.asMdiManager1.AddForm(frm);
		}

		private void menuItem7_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		
		private void menuItem9_Click(object sender, System.EventArgs e)
		{
			this.asMdiManager1.CloseAllForm();
		}

		
		private void menuItem12_Click(object sender, System.EventArgs e)
		{
			AboutForm frm = new AboutForm();
			frm.ShowDialog();
		}


	}
}
